package model.dao;

import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;
import java.util.List;

import model.domain.accDTO;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class accDAO {
	private static SqlMapClient client = null;
	
	static{
		try{
			Reader reader = Resources.getResourceAsReader("conf/SqlMapConfig.xml");
			client = SqlMapClientBuilder.buildSqlMapClient(reader);
			reader.close();
		}catch(IOException e){
			System.out.println("DAO문제");
			e.printStackTrace();
		}
	}
	
	public static void insertAccClick(accDTO dto) throws SQLException{
		System.out.println("DAOinsert함수 실행전");
		client.insert("accClick.insertAccClick", dto);
		System.out.println("DAOinsert함수 실행후");
	}
	
	public static List selectTagId() throws SQLException{
		System.out.println("DAOselectTagId함수");
		return client.queryForList("accClick.selectTagId");
	}
	
	public static void updateAccClick(accDTO dto) throws SQLException{
		System.out.println("DAOupdate함수");
		client.update("accClick.updateAccClick",dto);
	}
	
	public static List selectRank() throws SQLException{
		System.out.println("DAO selectRank함수");
		return client.queryForList("accClick.selectRank");
	}
	
	public static void createTable(String userId) throws SQLException{
		client.update("accClick.createTable",userId);
	}
}
